/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.diamondsys.embrapa;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Pablo
 */
@Entity
@Table(name = "sistemas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Sistemas.findAll", query = "SELECT s FROM Sistemas s ORDER BY s.nomesistema ASC"),
    @NamedQuery(name = "Sistemas.findById", query = "SELECT s FROM Sistemas s WHERE s.id = :id"),
    @NamedQuery(name = "Sistemas.findByNomesistema", query = "SELECT s FROM Sistemas s WHERE s.nomesistema = :nomesistema")})
public class Sistemas implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 150)
    @Column(name = "nomesistema")
    private String nomesistema;
    @Lob
    @Size(max = 2147483647)
    @Column(name = "mural")
    private String mural;
    @JoinTable(name = "permissao", joinColumns = {
        @JoinColumn(name = "sistemas_id", referencedColumnName = "id")}, inverseJoinColumns = {
        @JoinColumn(name = "tb_inst_cod_instituicao", referencedColumnName = "cod_instituicao")})
    @ManyToMany
    private List<TbInst> tbInstList;

    public Sistemas() {
    }

    public Sistemas(Integer id) {
        this.id = id;
    }

    public Sistemas(Integer id, String nomesistema) {
        this.id = id;
        this.nomesistema = nomesistema;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNomesistema() {
        return nomesistema;
    }

    public void setNomesistema(String nomesistema) {
        this.nomesistema = nomesistema;
    }

    public String getMural() {
        return mural;
    }

    public void setMural(String mural) {
        this.mural = mural;
    }

    @XmlTransient
    public List<TbInst> getTbInstList() {
        return tbInstList;
    }

    public void setTbInstList(List<TbInst> tbInstList) {
        this.tbInstList = tbInstList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sistemas)) {
            return false;
        }
        Sistemas other = (Sistemas) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.diamondsys.embrapa.Sistemas[ id=" + id + " ]";
    }
    
}
